package croppingplanap;

import java.awt.Color;

public class Category {

	private String name;
	private int id;
	private int cropCount;
	private float hue;
	private float saturation;
	private float constBrightness;
	Category successor;
	
	
	private boolean canBeInstanced;
	
	public static final Category NOTHING = new Category("Nothing", -1, 0f, 0f, 1f);
	public static final Category COVER_CROP = new Category("Cover Crop", -2, 0f, 0f, .75f);
	public static final Category RESEARCH = new Category("Research", -3, 0f, 0f,.5f);
	
	
	public Category(String name, int id, float hue){
		cropCount = 0;
		this.name = name;
		this.id = id;
		this.hue = hue;
		
		// This setting for saturation gives low saturation for hue values that would
		// otherwise produce unnatural greens and purples. 
		//boolean b = (hue >= .17f && hue < .33f) || (hue > .6f);	
		//saturation = b ? .25f : .75f;
		saturation = .5f;
		//saturation = (hue >= .1f && hue < .6f) ? .75f : .25f;		
		//saturation = (hue > .5f) ? .25f : .75f;
		canBeInstanced = true;
		successor = null;
	}
	
	private Category(String name, int id, float hue, float saturation, float brightness){
		this.name = name;
		this.id = id;
		this.hue = hue;
		this.saturation = saturation;
		constBrightness = brightness;
		canBeInstanced = false;
		successor = null;
	}
	
	public String toString(){
		return name;
	}
	
	public Color getNextColor(){
		if(canBeInstanced){
			float brightness;
			if(cropCount < 10){
				// IG: let's try this out... Go from brighter to darker. 
				// Hopefully steps of .08 aren't too small. 
				brightness = .90f -.08f * ((float)cropCount);		
				//brightness = .1f * ((float)cropCount) + .6f;
			}/*else if(cropCount < 20){
				brightness = .05f * ((float)cropCount) - .4f;
			}*/else{
				brightness = (float)(Math.random());
			}
			cropCount++;
			return Color.getHSBColor(hue, saturation, brightness);
		}else{
			cropCount++;
			return Color.getHSBColor(hue, saturation, constBrightness);
		}
	}
	
	public int getCropCount(){
		return cropCount;
	}
	
	public int getId(){
		return id;
	}
	
}
